package com.smedi.ismedi.progress.core.domain.aggregatemodel;


import lombok.*;


import java.time.LocalDateTime;

import static com.smedi.ismedi.progress.core.infrastructure.constant.ConstantField.*;

/**
 *
 *
 * @author liaojiajie
 * @date 2022/09/29
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ProgressReportDetail {

    /**
     * 主键id
     */
    private  Long	id;
    /**
     * (任务/里程碑)名称
     */
    private  String	name;
    /**
     * 类型(0、里程碑 1、关键任务  3、其他 4.一级任务)
     */
    private  Long	type;
    /**
     * 项目id
     */
    private  Long	projectId;
    /**
     * 关联progress_week_month_report表id
     */
    private  Long	progressWeekMonthReportId;
    /**
     * 计划开始时间
     */
    private  LocalDateTime	scheduleStartTime;
    /**
     * 计划完成时间
     */
    private  LocalDateTime	scheduleEndTime;
    /**
     * 实际开始时间
     */
    private  LocalDateTime	realStartTime;
    /**
     * 实际完成时间
     */
    private  LocalDateTime	realEndTime;
    /**
     * 完成情况(0、未完成  1、完成)
     */
    private  Long	completion;
    /**
     * 进度状态(0、滞后  1、正常)
     */
    private  Long	status;
    /**
     * 滞后时长
     */
    private  String	lagTime;

    public void setLagTime(Long lagTime) {
        if (lagTime > ZERO && lagTime < THIRTY) {
            String day = lagTime.toString() + "天";
            this.lagTime = day;
        } else if (lagTime >= THIRTY && lagTime < THREE_SIX_FIVE) {
            Long time = lagTime / THIRTY;
            if (lagTime % THIRTY == ZERO) {
                String month = time.toString() + "个月";
                this.lagTime = month;
            } else {
                Long day = lagTime % THIRTY;
                this.lagTime = time.toString() + "个月" + day + "天";
            }
        } else if (lagTime > THREE_SIX_FIVE) {
            Long time = lagTime / THREE_SIX_FIVE;
            if (lagTime % THREE_SIX_FIVE == ZERO) {
                String year = time + "年";
                this.lagTime = year;
            } else if (lagTime % THREE_SIX_FIVE >= THIRTY) {
                Long month = lagTime % THREE_SIX_FIVE / THIRTY;
                if (lagTime % THREE_SIX_FIVE == THIRTY) {
                    this.lagTime = time.toString() + "年" + month.toString() + "月";
                } else {
                    Long day = lagTime % THREE_SIX_FIVE % THIRTY;
                    this.lagTime = time.toString() + "年" + month.toString() + "月" + day.toString() + "天";
                }
            } else {
                Long day = lagTime % THREE_SIX_FIVE;
                this.lagTime = time.toString() + "年" + day + "天";
            }
        } else {
            this.lagTime = null;
        }
    }
    /**
     * 照片url
     */
    private  String	photoUrl;
    /**
     * 完成百分比
     */
    private  String	percentage;
    /**
     * 创建用户的id
     */
    private  Long	createdUserId;
    /**
     * 创建日期
     */
    private  LocalDateTime	createdDate;
    /**
     * 最后更新时间
     */
    private  LocalDateTime	latestUpdatedDate;
    /**
     * 最后更新的用户id
     */
    private  Long	latestUpdatedUserId;


}